﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace com.sharepointutils.application2007
{
    public class SP07Query
    {
        public String Query { get; set; }
        public String QueryOptions { get; set; }
        public int RowLimit { get; set; }
        public String ViewName { get; set; }
        public String ViewFields { get; set; }
        public String WebID { get; set; }

        public String ToXML()
        {
            StringBuilder xml = new StringBuilder();

            if (!String.IsNullOrWhiteSpace(Query))
            {
                xml.AppendFormat("<query>{0}</query>", Query);
            }

            if (!String.IsNullOrWhiteSpace(ViewFields))
            {
                xml.AppendFormat("<viewFields>{0}</viewFields>", ViewFields);
            }

            if (!String.IsNullOrWhiteSpace(WebID))
            {
                xml.AppendFormat("<webID>{0}</webID>", WebID);
            }

            if (!String.IsNullOrWhiteSpace(QueryOptions))
            {
                xml.AppendFormat("<queryOptions>{0}</queryOptions>", QueryOptions);
            }

            if (!String.IsNullOrWhiteSpace(ViewName))
            {
                xml.AppendFormat("<viewName>{0}</viewName>", ViewName);
            }

            if (0 != RowLimit)
            {
                xml.AppendFormat("<rowLimit>{0}</rowLimit>", RowLimit);
            }

            return xml.ToString();
        }

    }
}
